import 'package:flutter/material.dart';
import 'package:flutter_first/utils/spUtil.dart';

class FlatDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('FlatButton扁平按钮组件'),
      ),
      body: Column(
        children: <Widget>[
          FlatButton(
            // 文本
            child: Text(
              '点击登录按钮',
              style: TextStyle(fontSize: 26.0),
            ),
            // 按钮背景色
            color: Colors.green,
            // 按钮亮度
            colorBrightness: Brightness.dark,
            // 禁用时的背景色
            disabledColor: Colors.grey,
            // 禁用时的文本色
            disabledTextColor: Colors.grey[500],
            // 文本颜色
            textColor: Colors.white,
            // 按钮主题 ButtonTheme ButtonThemeData ButtonTextTheme ThemeData
            textTheme: ButtonTextTheme.normal,
            // 点击效果颜色
            splashColor: Colors.blue,
            // 抗锯齿能力
            clipBehavior: Clip.antiAlias,
            // 内边距
            padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 20.0),
            // 边框样式
//            shape: Border.all(
//              width: 2.0,
//              color: Colors.deepPurple,
//              style: BorderStyle.solid
//            ),
            // 边框圆角样式
            shape: RoundedRectangleBorder(
                side: BorderSide(
                    width: 2.0,
                    color: Colors.deepPurple,
                    style: BorderStyle.solid),
                borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(10.0),
                    topRight: Radius.circular(10.0),
                    bottomLeft: Radius.circular(10.0),
                    bottomRight: Radius.circular(10.0))),
            onPressed: () => print('按钮点击操作'),
          ),

          // 带图标的按钮
          TextButton.icon(
            onPressed: () => Navigator.pop(context),
            icon: Icon(Icons.android, size: 28.0),
            label: Text(
              '点击返回上一级',
              style: TextStyle(fontSize: 26.0),
            ),
            style: TextButton.styleFrom(
              primary: Colors.grey[850], //字体颜色
              backgroundColor: Colors.yellow,
              padding: EdgeInsets.symmetric(horizontal: 15.0, vertical: 8.0),
              shape: StadiumBorder(
                side: BorderSide(color: Colors.yellow, style: BorderStyle.solid),
              ),
            ),
          ),

          OutlinedButton(
            onPressed: () async {
              await SpUtil.clear();
              print("边框按钮点击");
            },
            child: Text(
              '清除share缓存',
              style: TextStyle(fontSize: 16.0),
            ),
            style: OutlinedButton.styleFrom(
              primary: Colors.grey[850], //字体颜色
              padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0),
              side: BorderSide(
                  width: 2.0, color: Colors.yellow, style: BorderStyle.solid),
              shape: StadiumBorder(),
            ),
          )
        ],
      ),
    );
  }
}
